import org.junit.*;
import java.util.*;
import play.test.*;
import models.*;
public class Amira extends UnitTest{

	@Test
	public void createIdeaDeveloperOrganizationEntity(){
		IdeaDeveloper ideaDeveloper1 =
			new IdeaDeveloper("AmiraAli ","Amira Elshimy","123456","amira@guc.edu.eg"
					,"17/8/1991","lalal");
		ideaDeveloper1.save();
		IdeaDeveloper ideaDeveloper2 =
			new IdeaDeveloper("ghadeer ","ghadeerAbdelKader","123443454","ghadeer@guc.edu.eg"
					,"17/5/1991","lalal");
		ideaDeveloper2.save();
		Organization org1=new Organization();
		org1.save();
		OrganizationLead orgLead1= OrganizationLead.create(ideaDeveloper1);
		 org1.creator=orgLead1;
		 org1.save();

		 Organization org2=new Organization();
		 org2.save();
			OrganizationLead orgLead2= OrganizationLead.create(ideaDeveloper2);
			assertEquals("ghadeerAbdelKader",orgLead2.ideaDeveloper.username);
			 org2.creator=orgLead2;
			 org2.save();
	Entities entity1=new Entities();
	entity1.save();
	entity1.liesIn=org1;
	entity1.save();



	}
	@Test
	public void createTopicOrg(){
		IdeaDeveloper ideaDeveloper1 =
			new IdeaDeveloper("AmiraAli ","Amira Elshimy","123456","amira@guc.edu.eg"
					,"17/8/1991","lalal");
		ideaDeveloper1.save();
		Organization org1=new Organization();
		org1.save();
		OrganizationLead orgLead1= OrganizationLead.create(ideaDeveloper1);
		 org1.creator=orgLead1;
		 org1.save();
	Topic topic= Topic.createTopicOrg("yarab", "yamosahel", org1.id, ideaDeveloper1.id);
	topic.postATopic();
	 assertTrue(topic.published);

	}

        @Test
	public void createTopicEntity(){
		IdeaDeveloper ideaDeveloper1 =
			new IdeaDeveloper("AmiraAli ","Amira Elshimy","123456","amira@guc.edu.eg"
					,"17/8/1991","lalal");
		ideaDeveloper1.save();
		Organization org1=new Organization();
		org1.save();
		OrganizationLead orgLead1= OrganizationLead.create(ideaDeveloper1);
		 org1.creator=orgLead1;
		 org1.save();
                 Entities entity1=new Entities();
	entity1.save();
	entity1.liesIn=org1;
	entity1.save();
	Topic topic= Topic.createTopicEnt("yarab", "yamosahel", entity1.id, ideaDeveloper1.id);
	topic.postATopic();
	 assertTrue(topic.published);

	}

        @Test
        public void createTopicIdeaAndDeleteTheTopic(){

            IdeaDeveloper ideaDeveloper1 =
			new IdeaDeveloper("AmiraAliMohamed ","Amira Elshimy122222","123456","amira@guc.edu.eg"
					,"17/8/1991","lalal");
		ideaDeveloper1.save();
		Organization org1=new Organization();
		org1.save();
		OrganizationLead orgLead1= OrganizationLead.create(ideaDeveloper1);
		 org1.creator=orgLead1;
		 org1.save();
                  Entities entity1=new Entities();
	entity1.save();
	entity1.liesIn=org1;
	entity1.save();
	Topic topic= Topic.createTopicEnt("yarab", "yamosahel", entity1.id, ideaDeveloper1.id);
	topic.postATopic();

        topic.delete2();



        }

         @Test
        public void createIdeaOrg(){

            IdeaDeveloper ideaDeveloper1 =
			new IdeaDeveloper("AmiraAlielshimy ","Amira Elshimy","123456","amira@guc.edu.eg"
					,"17/8/1991","lalal");
		ideaDeveloper1.save();
		Organization org1=new Organization();
		org1.save();
		OrganizationLead orgLead1= OrganizationLead.create(ideaDeveloper1);
		 org1.creator=orgLead1;
		 org1.save();


        Idea idea1 =Idea.createIdeaOrg("Amira1", "amira", ideaDeveloper1.id, org1.id);
        Idea idea2 =Idea.createIdeaOrg("Amira2", "amira", ideaDeveloper1.id, org1.id);
        idea1.postAnIdea();
 assertEquals(1,Idea.find("title =?", "Amira1").fetch().size());
  assertEquals(1,Idea.find("title =?", "Amira2").fetch().size());

        }

         @Test
        public void createIdeaEnt(){

            IdeaDeveloper ideaDeveloper1 =
			new IdeaDeveloper("AmiraAli ","Amira Elshimy","123456","amira@guc.edu.eg"
					,"17/8/1991","lalal");
		ideaDeveloper1.save();
		Organization org1=new Organization();
		org1.save();
		OrganizationLead orgLead1= OrganizationLead.create(ideaDeveloper1);
		 org1.creator=orgLead1;
		 org1.save();
  Entities entity1=new Entities();
	entity1.save();
	entity1.liesIn=org1;
	entity1.save();

        Idea idea1 =Idea.createIdeaEntity("Amira3", "amira", ideaDeveloper1.id, entity1.id);
        Idea idea2 =Idea.createIdeaEntity("Amira4", "amira", ideaDeveloper1.id, entity1.id);
        idea2.postAnIdea();
assertEquals(1,Idea.find("title=?", "Amira3").fetch().size());
assertEquals(1,Idea.find("title=?", "Amira4").fetch().size());
        }
          @Test
        public void deleteIdea(){

            IdeaDeveloper ideaDeveloper1 =
			new IdeaDeveloper("AmiraAli ","Amira Elshimy","123456","amira@guc.edu.eg"
					,"17/8/1991","lalal");
		ideaDeveloper1.save();
		Organization org1=new Organization();
		org1.save();
		OrganizationLead orgLead1= OrganizationLead.create(ideaDeveloper1);
		 org1.creator=orgLead1;
		 org1.save();

        Idea idea1 =Idea.createIdeaOrg("Amira5", "amira", ideaDeveloper1.id, org1.id);
        Idea idea2 =Idea.createIdeaOrg("Amira6", "amira", ideaDeveloper1.id, org1.id);
        idea1.postAnIdea();
        idea1.delete2();
        idea2.delete2();
        assertEquals(0,Idea.find("title=?", "Amira5").fetch().size());
         assertEquals(0,Idea.find("title=?", "Amira6").fetch().size());


        }
          @Test
        public void reporIdeaAndCommentAsSpam(){

            IdeaDeveloper ideaDeveloper1 =
			new IdeaDeveloper("AmiraAli ","Amira Elshimy","123456","amira@guc.edu.eg"
					,"17/8/1991","lalal");
		ideaDeveloper1.save();
                IdeaDeveloper ideaDeveloper2 =
			new IdeaDeveloper("ghadeer ","ghadeer","123456","amira@guc.edu.eg"
					,"17/8/1991","lalal");
                ideaDeveloper2.save();
		Organization org1=new Organization();
		org1.save();
		OrganizationLead orgLead1= OrganizationLead.create(ideaDeveloper1);
		 org1.creator=orgLead1;
		 org1.save();


        Idea idea1 =Idea.createIdeaOrg("Amira", "amira", ideaDeveloper1.id,org1.id);
        Idea idea2 =Idea.createIdeaOrg("Amira", "amira", ideaDeveloper1.id, org1.id);
        idea1.reportAsSpam(ideaDeveloper2.id);
        assertEquals(1,idea1.spam.size());
        Comment.create(ideaDeveloper2, idea2, "amira");
        idea2.comments.get(0).reportAsSpam(ideaDeveloper1.id);
        idea2.comments.get(0).save();
         assertEquals(1,idea2.comments.get(0).spam.size());

        }



}